Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up window disabling #3642

Merged
merged 1 commit into from
Aug 21, 2022
Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Aug 21, 2022

Problem

In current dev builds, if you turn on automatic registry refreshing at launch in the settings, you can sometimes end up with the main menu disabled and the close button not working at startup.

Causes

  • In Many improvements for failed downloads #3635 and Update mod list through Wait.StartWaiting #3637 we tried to improve the Wait tab's encapsulation and how it's used, and some of those updates must have created a state where we disable the window and don't re-enable it, but I have not been able to pin down exactly how it happened.
  • Main.SwitchEnabledState is a toggle that keeps state in a private _enabled variable, but every place that calls it wants specifically to either enable or disable the window; there is no point where a toggle actually makes sense like it does with a checkbox. If that state gets out of sync unexpectedly, then those calls all flip, we disable when we mean to enable and vice versa, and we end up with a disabled window that can't be re-enabled.
    • Some places use Main.SwitchEnabledState and some enable or disable without it, which would be a great way for _enabled to get out of sync

Changes

  • Main.SwitchEnabledState from MainRepo.cs is split into Main.EnableMainWindow and Main.DisableMainWindow in Main.cs, and all calling code is updated to use the right one based on what is being done at that point
  • Every other place that I could find that enables or disables the tabs and menus is also updated to use Main.EnableMainWindow and Main.DisableMainWindow
  • The unused parameter of Wait.Finish and HideWaitDialog is removed

This fixes the bug and should help keep things more consistent in the future.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request labels Aug 21, 2022
@HebaruSan
Copy link
Member Author

I'm going to self-review and merge this so I can rebase other PRs and hand out test builds that don't have this problem, since I'm more confident in this branch than I am in master at this point...

@HebaruSan HebaruSan merged commit 193552c into KSP-CKAN:master Aug 21, 2022
@HebaruSan HebaruSan deleted the fix/window-disabling branch August 21, 2022 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant